<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/jsp/head.jsp"%>
<%@ include file="/jsp/jslib.jsp"%>
<script type="text/javascript">
PAGE_CONFIG = {
	'MENU_INDEX' : 2,'LI_INDEX' : 3
};
</script>
</head>

<body>
<%@ include file="/jsp/banner.jsp"%>
<div class="am-cf admin-main">
    <%@ include file="/jsp/menu.jsp"%>
	
	<!-- content start -->
	<div class="admin-content">
		<div class="admin-content-body">
		
		<!-- ***** 分离出去 动态加载 start ***** -->
		
		<div class="admin-content-body">
		    <div class="am-cf am-padding am-padding-bottom-0">
		        <div class="am-fl am-cf">
		            <strong class="am-text-primary am-text-lg"> 编辑员工 </strong>
		        </div>
		    </div>
		    
		    <hr>
		    
            <form action="${ctx}/staff/insertorupdate" method="post" class="am-form">
            	
                <div class="am-g am-margin-top">
                	<div class="am-u-sm-4 am-u-md-2 am-text-right"> 员工编号 </div>
                    <div class="am-u-sm-8 am-u-md-4">
	                	<input id="staffId" name="staffId" value="${param.staffId}" type="text" class="am-input-sm" readonly>
	                </div>
                    <div class="am-hide-sm-only am-u-md-6">  </div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-4 am-u-md-2 am-text-right"> 员工姓名 </div>
                    <div class="am-u-sm-8 am-u-md-4">
                        <input id="staffName" name="staffName" value="${param.staffName}" type="text" class="am-input-sm" readonly  required>
                    </div>
                    <div class="am-hide-sm-only am-u-md-6">  </div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-4 am-u-md-2 am-text-right"> 职位 </div>
                    <div class="am-u-sm-8 am-u-md-4">
                        <select id="positionId" name="positionId" required <c:if test="${sessionScope.permission != 1 && sessionScope.permission != 2}">disabled="disabled"</c:if>>
                        	<c:forEach items="${sessionScope.fgPositionList}" var = "position" >
		           				<option value="${position.positionId}"
		           					<c:if test="${z}">selected</c:if>
		           				>${position.positionName}</option>
		           			</c:forEach>
                        </select>
                    </div>
                    <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-4 am-u-md-2 am-text-right"> 所属部门 </div>
                    <div class="am-u-sm-8 am-u-md-4">
                        <select id="companyId" name="companyId" required <c:if test="${sessionScope.permission != 1 && sessionScope.permission != 2}">disabled="disabled"</c:if>>
                        	<c:forEach items="${sessionScope.fgCompanyList}" var = "company" >
		           				<option value="${company.companyId}"
		           					<c:if test="${company.companyId == param.companyId}">selected</c:if>
		           				>${company.companyName}</option>
		           			</c:forEach>
                        </select>
                    </div>
                    <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
                </div>
                <div class="am-g am-margin-top">
                    <div class="am-u-sm-4 am-u-md-2 am-text-right"> 权限 </div>
                    <div class="am-u-sm-8 am-u-md-4">
                        <select id="permission" name="permission" required <c:if test="${sessionScope.permission != 1 && sessionScope.permission != 2}">disabled="disabled"</c:if>>
                            
                            <option value="2" <c:if test="${param.permission == 2}">selected</c:if> disabled>管理员</option>
                            <option value="0" <c:if test="${param.permission == 0}">selected</c:if>>员工</option>
                            <option value="1" <c:if test="${param.permission == 1}">selected</c:if>>主管</option>
                        </select>
                    </div>
                    <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
                </div>
                
                <div class="am-margin">
			        <c:if test="${sessionScope.permission == 1 || sessionScope.permission == 2}">
			        	<button type="submit" class="am-btn am-btn-primary am-btn-sm am-margin-sm"> 保 存 </button>
			        </c:if>
			        <button type="button" id="reset_password" class="am-btn am-btn-primary am-btn-sm am-margin-sm" > 重置密码 </button>
			        <button type="button" class="am-btn am-btn-primary am-btn-sm am-margin-sm" onclick="javascript:window.location.href='${ctx}/staff/all'"> 返 回 </button>
			    </div>
            </form>
		</div>
	</div>
</div>
</div>
</body>

<script type="text/javascript">
$('#reset_password').click(function () {
	$.ajax({
        type: "POST",
        async:false,
        url: "self/resetpassword",
        data : {
        	"staffId" : '${param.staffId}'
        },
        success: function(msg) {
        	alert(msg);
        }
    });
});
</script>

</html>